//
//  PKLiveStarView.swift
//  Panku
//
//  Created by mac on 2017/2/14.
//  Copyright © 2017年 Monster. All rights reserved.
//

import UIKit
import SnapKit

class PKLiveStarView: PKBaseView {
    
    //MARK: - properties
    var name:String?
    var watchingCount:Int?
    
    //MARK: - init
    init(name:String,watchingCount:Int){
        super.init()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //MARK: - properties
    lazy var avatarView = PKBaseView()
    lazy var nameView = UILabel()
    lazy var watchingCountLabel = UILabel()
    lazy var followButton = PKBaseButton.createButton()
    
    override func setupView() {
        self.frame = CGRect(x: 0, y: 0, width: 150, height: 100)
        self.backgroundColor = UIColor.black
        self.layer.cornerRadius = 50
        self.layer.masksToBounds = true
        
        self.addSubview(avatarView)
        self.addSubview(nameView)
        self.addSubview(watchingCountLabel)
        self.addSubview(followButton)
        
        avatarView.layer.cornerRadius = 45
        avatarView.layer.masksToBounds = true
        avatarView.backgroundColor = UIColor.white
        avatarView.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.left.equalTo(self.snp.left).offset(5)
        }
        
        nameView.text = "当你沉默了之后你会看直播"
        nameView.textColor = UIColor.white
        nameView.snp.makeConstraints { (make) in
            make.top.equalTo(avatarView.snp.top)
            make.left.equalTo(avatarView.snp.right).offset(5)
        }
        
        watchingCountLabel.textColor = UIColor.darkGray
        watchingCountLabel.text = "2451人在看"
        watchingCountLabel.snp.makeConstraints { (make) in
            make.left.equalTo(nameView.snp.left)
            make.top.equalTo(nameView.snp.bottom).offset(5)
        }
        
        followButton.backgroundColor = UIColor.white
        followButton.addBlock(for: .touchUpInside) { (_) in
            //TODO:关注操作
            
        }
        followButton.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.right.equalTo(self.snp.right).offset(5)
            make.width.equalTo(100)
            make.height.equalTo(44)
        }
        followButton.layer.cornerRadius = 22
        followButton.layer.masksToBounds = true
        followButton.setTitle("关注", for: .normal)
        
    }

}
